import random
import time


# 游戏模块
def play():
    global money
    answer = 0
    for i in range(3):
        a = random.randint(1, 6)
        answer += a
    print(f"结果为：{answer}")
    if guess == "小" and answer <= 10 or guess == "大" and answer >= 11:
        print("你赢了！获得100金豆！")
        money += 100`
        print(f"你现在还有{money}金豆")
        print("--------------------")
    else:
        print("你输了！失去100金豆！")
        money -= 100
        print(f"你现在还有{money}金豆")
        print("--------------------")


# 用户登录模块
def sign():
    while True:
        for i in range(3):
            name = input("输入用户名:")
            passwd = input("请输入密码:")
            if name == "root" and passwd == "123456":
                print("登录成功，欢迎您root!")
                print(f"你现在还有{money}金豆")
                return
            else:
                print(f"已登录失败{i + 1}次，最多登录失败三次！")
        else:
            print("已超过尝试次数！请五秒后再试！")
            time.sleep(5)


def menu():
    print("游戏规则：\n"
          "三个色子和在3~10 => 小， 11~18=>大\n"
          "输入exit退出游戏\n"
          "输入help再次查看菜单\n"
          "-------------------------------")


# 初始化money
money = 1000


# 金豆模块，有代升级
def money_sys():
    global money
    money = 1000



# 登入系统
print("ps.现在版本比较低，请用试玩账号root,密码为123456")
sign()
# 输出菜单
menu()
# 死循环让游戏不断进行
while 1:
    guess = input("请猜测大小：")
    if guess == "大" or guess == "小":
        play()
    elif guess == "help":
        menu()
    elif guess == "exit":
        print("欢迎下次游玩！")
        break
    else:
        print("请输入正确选项！")
